/**
 * @file gate.c
 * @brief function definitions for manipulating logic gates
 * @author Scott Moyers
 * @date 2008
 */

#include "gate.h"

#define INV_WEIGHT (0.2f)
static const float gate_weights[GATE_TYPES] = {
	INV_WEIGHT * 4,
	INV_WEIGHT * 3,
	INV_WEIGHT * 4,
	INV_WEIGHT * 3,
	INV_WEIGHT * 8,
	INV_WEIGHT * 6,
	INV_WEIGHT,
	0.0
};

static const char *gate_name[GATE_TYPES] = {
	"and ",
	"nand",
	"or  ",
	"nor ",
	"xor ",
	"xnor",
	"inv ",
	"zero"
};

/**
 * the number of inputs each gate type has
 */
const unsigned int num_inputs_arr[GATE_TYPES] = {2, 2, 2, 2, 2, 2, 1, 0};

float get_gate_weight(struct Gate *g)
{
	return gate_weights[g->gate_type];
}

const char *get_gate_name(struct Gate *g)
{
	return gate_name[g->gate_type];
}

unsigned int num_gate_inputs(struct Gate *g)
{
	return num_inputs_arr[g->gate_type];
}
